function getUrlParam(name) {
    var reg = new RegExp("(^|&)"+name+"=([^&]*(&|$))");
    var r = window.location.search.substr(1).match(reg);
    if  (r != null) return unescape(r[2]);return null;
}

function getNowFormatDate(str) {
    let nowDate = new Date()
    if (str != undefined && str.length != 0) {
        nowDate = new Date(str)
    }
    var year = nowDate.getFullYear();
    var month = ('0'+(nowDate.getMonth()+1)).slice(-2);
    var date =('0'+(nowDate.getDate())).slice(-2);
    return year+'-'+month+'-'+date
}

function getNowFormatTime() {
    let nowDate = new Date()
    var year = nowDate.getFullYear();
    var month = ('0'+(nowDate.getMonth()+1)).slice(-2);
    var date =('0'+(nowDate.getDate())).slice(-2);
    var hour = nowDate.getHours();
    var minute = nowDate.getMinutes();
    var second = nowDate.getSeconds();
    return year+'-'+month+'-'+date+' '+hour+':'+minute+':'+second
}

function canvasDaraUrl(file) {
    var b64img = ''
    var reader = new FileReader()
    reader.readAsDataURL(file)
    reader.onload = function (e) {
        const img = new Image()
        const quality = 0.8
        const canvas = document.createElement('canvas')
        const drawer = canvas.getContext('2d')
        img.src = this.result
        img.onload = function () {
            canvas.width = img.width
            canvas.height = img.height
            drawer.drawImage(img,0,0,canvas.width,canvas.height)
            b64img = canvas.toDataURL(file.type,quality)
        }
    }
    return b64img
}